<?php

namespace Lazzaroni\UsuarioBundle\Entity;

use Doctrine\ORM\EntityRepository;

class UsuarioRepository extends EntityRepository {

    //ACA VAN LAS CONSULTAS COMPLEJAS Y SIMPLES (find, findall, findby y findoneby )
    public function findOneByUserName($username) {

        $em = $this->getEntityManager();

        $dql = 'SELECT u FROM UsuarioBundle:Usuario u WHERE u.username = :username';

        $consulta = $em->createQuery($dql);
        $consulta->setParameter('username', $username);
        $consulta->setMaxResults(1);

        return $consulta->getOneOrNullResult();
    }
    


}
